This page last changed on Feb 16, 2006 by dblasby.

This info isnt accurate -- but leave it here for a bit as there's some interesting text that can be moved out.

Dont read this -- head over to

[SLD Explanations and Samples]

where there's lots of good info.

 

----------------------------- 

 

(A user asked about putting a North Arrow and a copyright notice on a map. These are easiest to do with SLD & inlinefeature. I thought this would be a good opportunity to start a wiki page on adding inlinefeature and using SLD-post. Please edit this page to make it better.)

The easiest way to do "acetate" layers is with <InlineFeature> in an SLD-post request to the WMS.

You might think this is a bit difficult, but its actually not.

I'll try to explain it - hopefully we can get this solved and we can setup a wiki page so other users can also do this.

Lets look at doing the copyright info first (since its easy).

I suggest you look at my MUM3 presentation since it explains most of what I'm going to talk about:
http://docs.codehaus.org/display/GEOS/OSGIS+2005+presentation

We're going to do this in 3 steps:
1. make an SLD-post request to get your map
a) make the SLD
b) change the request URL to use the SLD
2. add a new layer (the inlinefeature layer)
3. make a custom styling for the inlinefeature

1. make an SLD-post request to get your map

Its easy to translate a "normal" (layers=a,b,c&styles=style_a,style_b,style_c) request to an SLD request:

<?xml version="1.0" encoding="UTF-8"?>
<StyledLayerDescriptor version="1.0.0"
         xmlns:gml="http://www.opengis.net/gml"
          xmlns:ogc="http://www.opengis.net/ogc"
          xmlns="http://www.opengis.net/sld">

<NamedLayer>
    <Name>a</Name>
    <NamedStyle>
         <Name>style_a</Name>
    </NamedStyle>
</NamedLayer>

<NamedLayer>
    <Name>b</Name>
    <NamedStyle>
         <Name>style_b</Name>
    </NamedStyle>
</NamedLayer>

<NamedLayer>
    <Name>c</Name>
    <NamedStyle>
         <Name>style_c</Name>
    </NamedStyle>
</NamedLayer>

</StyledLayerDescriptor>

 

You can then make a normal WMS request, but instead of the "layers=...,styles=..." portion, just use SLD_BODY=<SLD from above all on one line>.

Yes, this is unwieldly.

http://localhost:8080/geoserver/wms?request=GetMap&...&SLD_BODY=<StyledLayerDescriptor version="1.0.0"          xmlns:gml="http://www.opengis.net/gml"          mlns:ogc="http://www.opengis.net/ogc"          xmlns="http://www.opengis.net/sld"><NamedLayer>    <Name>a</Name>    <NamedStyle>         Name>style_a</Name>    </NamedStyle></NamedLayer><NamedLayer>    <Name>b</Name>    NamedStyle>         <Name>style_b</Name>    </NamedStyle></NamedLayer><NamedLayer>    <Name>c</Name>    <NamedStyle>         <Name>style_c</Name>    </NamedStyle></NamedLayer> </StyledLayerDescriptor>

 

Next, you add the <UserLayer> (with an <InlineFeature> and a <UserStyle>):

<?xml version="1.0" encoding="UTF-8"?>
<StyledLayerDescriptor version="1.0.0"
         xmlns:gml="http://www.opengis.net/gml"
          xmlns:ogc="http://www.opengis.net/ogc"
          xmlns="http://www.opengis.net/sld">

<NamedLayer>
    <Name>a</Name>
    <NamedStyle>
         <Name>style_a</Name>
    </NamedStyle>
</NamedLayer>

<NamedLayer>
    <Name>b</Name>
    <NamedStyle>
         <Name>style_b</Name>
    </NamedStyle>
</NamedLayer>

<NamedLayer>
    <Name>c</Name>
    <NamedStyle>
         <Name>style_c</Name>
    </NamedStyle>
</NamedLayer>

<UserLayer>
   <Name>junk</Name>
   <InlineFeature>
        <mybbox>
               <the_geom>
                        <gml:Box srsName="4326"><gml:coordinates>-122.63,37.44 -121.36,38.24</gml:coordinates></gml:Box>
               </the_geom>
        </mybbox>
   </InlineFeature>
   <LayerFeatureConstraints>
      <FeatureTypeConstraint>
      </FeatureTypeConstraint>
   </LayerFeatureConstraints>

   <UserStyle>
      <FeatureTypeStyle>
          <Rule>
              <TextSymbolizer>
                   ...SEE BELOW...
              </TextSymbolizer>
          </Rule>
      </FeatureTypeStyle>
    </UserStyle>
</UserLayer>

</StyledLayerDescriptor>

 

NOTE: The actual content of the feature for InlineFeature is not important because we're going to position it absolutely on the screen.

NOTE: due to the current labeling system in GeoTools, you may find that the copyright label dissappears when there's another label on top of it. We're going to fix this at some point in time.

If you read the definition of the TextSymbolizer in the SLD specification, we can label something by giving it a location on the image.

-------oops, missread the specification; thats relative-to-the-geometries-bbox, not absolute ---------------

<?xml version="1.0" encoding="UTF-8"?><StyledLayerDescriptor version="1.0.0" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" xmlns="http://www.opengis.net/sld"><NamedLayer><Name>topp:World_countries_shp</Name><NamedStyle><Name>world_country</Name></NamedStyle></NamedLayer><NamedLayer><Name>topp:statesp020</Name><NamedStyle><Name>usa_states</Name></NamedStyle></NamedLayer><NamedLayer><Name>topp:cities</Name><NamedStyle><Name>world_cities</Name></NamedStyle></NamedLayer><NamedLayer><Name>topp:citiesx020</Name><NamedStyle><Name>usa_city</Name></NamedStyle></NamedLayer><UserLayer><Name>bbox</Name><InlineFeature><mybbox><the_geom><gml:Box srsName="4326"><gml:coordinates>-122.63,37.44 \-121.36,38.24</gml:coordinates></gml:Box></the_geom></mybbox></InlineFeature><LayerFeatureConstraints><FeatureTypeConstraint></FeatureTypeConstraint></LayerFeatureConstraints><UserStyle><FeatureTypeStyle><Rule><LineSymbolizer><Stroke><CssParameter name="stroke"><ogc:Literal>#FF1111</ogc:Literal></CssParameter><CssParameter name="stroke-width"><ogc:Literal>3</ogc:Literal></CssParameter></Stroke></LineSymbolizer></Rule></FeatureTypeStyle></UserStyle></UserLayer></StyledLayerDescriptor>

[http://localhost:8080/geoserver/wms?validateSchema=true&amp;FORMAT=image/png&amp;TRANSPARENT=TRUE&amp;HEIGHT=406&amp;REQUEST=GetMap&amp;WIDTH=810&amp;SRS=EPSG:4326&amp;VERSION=1.1.1&amp;BBOX=-123.99007389162563,36.839999999999996,-119.99992610837438,38.84&amp;SLD_BODY=]<?xml version="1.0" encoding="UTF-8"?><StyledLayerDescriptor version="1.0.0" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" xmlns="http://www.opengis.net/sld"><NamedLayer><Name>topp:World_countries_shp</Name><NamedStyle><Name>world_country</Name></NamedStyle></NamedLayer><NamedLayer><Name>topp:statesp020</Name><NamedStyle><Name>usa_states</Name></NamedStyle></NamedLayer><NamedLayer><Name>topp:cities</Name><NamedStyle><Name>world_cities</Name></NamedStyle></NamedLayer><NamedLayer><Name>topp:citiesx020</Name><NamedStyle><Name>usa_city</Name></NamedStyle></NamedLayer><UserLayer><Name>bbox</Name><InlineFeature><mybbox><the_geom><gml:Point srsName="4326"><gml:coordinates>-122.63,37.44</gml:coordinates></gml:Point></the_geom></mybbox></InlineFeature><LayerFeatureConstraints><FeatureTypeConstraint></FeatureTypeConstraint></LayerFeatureConstraints><UserStyle><FeatureTypeStyle> <Rule> <TextSymbolizer> <Label> Create Commons Map License </Label> <Font><CssParameter name="font-family">Times New Roman</CssParameter><CssParameter name="font-style">Normal</CssParameter><CssParameter name="font-size">14</CssParameter><CssParameter name="font-weight">bold</CssParameter></Font> <LabelPlacement> <PointPlacement> <AnchorPoint> <AnchorPointX> 0.1 </AnchorPointX> <AnchorPointY> 0.1 </AnchorPointY> </AnchorPoint> </PointPlacement> </LabelPlacement> </TextSymbolizer></Rule> </FeatureTypeStyle></UserStyle></UserLayer></StyledLayerDescriptor>

<Rule><LineSymbolizer><Stroke><CssParameter name="stroke"><ogc:Literal>#FF1111</ogc:Literal></CssParameter><CssParameter name="stroke-width"><ogc:Literal>3</ogc:Literal></CssParameter></Stroke></LineSymbolizer></Rule>

<Rule> <TextSymbolizer> <Label> Create Commons Map License </Label> <LabelPlacement> <PointPlacement> <AnchorPointX> 0.1 </AnchorPointX> <AnchorPointY> 0.1 </AnchorPointY> </PointPlacement> </LabelPlacement> </TextSymbolizer></Rule>

<Rule>
 <TextSymbolizer>
 <Label> Create Commons Map License </Label>

<Font>
 <CssParameter name="font-family">Times New Roman</CssParameter>
 <CssParameter name="font-style">Normal</CssParameter>
 <CssParameter name="font-size">14</CssParameter>
 <CssParameter name="font-weight">bold</CssParameter>
 </Font>

<LabelPlacement>

<PointPlacement>
 <AnchorPoint>
 <AnchorPointX>
 0.1
 </AnchorPointX>
 <AnchorPointY>
 0.1
 </AnchorPointY>
 </AnchorPoint>

</PointPlacement>

</LabelPlacement>

<Fill>

</Fill>
 </TextSymbolizer>
</Rule>

<Font><CssParameter name="font-family">Times New Roman</CssParameter><CssParameter name="font-style">Normal</CssParameter><CssParameter name="font-size">14</CssParameter><CssParameter name="font-weight">bold</CssParameter></Font>

 

Document generated by Confluence on Jan 16, 2008 23:27